package com.atguigu.yygh.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.service.IHospitalService;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
@author kabuda
@create 2023-02-27 10:32
*/
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private IHospitalService hospitalService;

    @GetMapping("/list/{page}/{limit}")
    public Result list(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel=hospitalService.list(page, limit,hospitalQueryVo);

        return Result.ok(pageModel);
    }

    @GetMapping("/updateStatus/{id}/{status}")
    public Result updateStatus(@PathVariable("id")String id,@PathVariable("status") Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    @GetMapping("/show/{id}")
    public Result<Map<String, Object>> showHospitalInfo(@PathVariable("id")String id){
        Map<String,Object> map=hospitalService.showHospitalInfo(id);
        return Result.ok(map);
    }

}
